import request from '@/utils/request'

// 获取车辆列表
export const getVehicleAPI = (params) => {
  return request({
    url: '/manager/truck/page',
    method: 'get',
    params: params
  })
}

// 获取车辆类型数据
export const getVehicleTypeAPI = (params) => {
  return request({
    url: '/manager/truckType/page',
    method: 'get',
    params: params
  })
}

// 获取车辆类型信息列表
export const getVehicleTypeListAPI = () => {
  return request({
    url: '/manager/truckType/simple',
    method: 'get'
  })
}

// 新增车辆类型
export const addVehicleTypeAPI = (
  { allowableLoad, allowableVolume, measureHigh, measureLong, measureWidth, name }
) => {
  return request({
    url: '/manager/truckType',
    method: 'post',
    data: {
      allowableLoad,
      allowableVolume,
      measureHigh,
      measureLong,
      measureWidth,
      name
    }
  })
}

// 获取车辆详情
export const getVehicleDetailAPI = (id) => {
  return request({
    url: '/manager/truck/' + id,
    method: 'get'
  })
}

// 获取车型详情
export const getVehicleTypeDetailAPI = (id) => {
  return request({
    url: '/manager/truckType/' + id,
    method: 'get'
  })
}

// 添加车辆
export const addVehicleAPI = (data) => {
  return request({
    url: '/manager/truck',
    method: 'post',
    data: data
  })
}

// 更新车辆信息
export const updateVehicleAPI = (id,
  { allowableLoad, allowableVolume, deviceGpsId, licensePlate, picture, truckTypeId, truckTypeName }
) => {
  return request({
    url: '/manager/truck/' + id,
    method: 'put',
    data: {
      allowableLoad, allowableVolume, deviceGpsId, licensePlate, picture, truckTypeId, truckTypeName
    }
  })
}
// 更新车辆类型信息
export const updateVehicleTypeAPI = (id,
  { allowableLoad, allowableVolume, measureHigh, measureLong, measureWidth, goodsTypes = [], name, num }
) => {
  return request({
    url: '/manager/truckType/' + id,
    method: 'put',
    data: {
      allowableLoad,
      allowableVolume,
      goodsTypes,
      id,
      measureHigh,
      measureLong,
      measureWidth,
      name,
      num
    }
  })
}
// 删除车辆类型信息
export const delVehicleTypeAPI = (id) => {
  return request({
    url: '/manager/truckType/' + id,
    method: 'delete'
  })
}

// 停用车辆
export const disableVehicleAPI = (id) => {
  return request({
    url: '/manager/disable/' + id,
    method: 'put'
  })
}

// 启用车辆
export const enableVehicleAPI = (id) => {
  return request({
    url: '/manager/enable/' + id,
    method: 'put',
    params: { id: id }
  })
}

// 获取树状机构数据
export const getTreeDataAPI = () => {
  return request({
    url: '/manager/business-hall/tree',
    method: 'get'
  })
}

// 查询回车登记列表
export const getVehicleReturnAPI = (data) => {
  return request({
    url: '/manager/truck-return-register/pageQuery',
    method: 'post',
    data: data
  })
}

// 获取绑定司机数据
export const getbindingDriverAPI = (truckId) => {
  return request({
    url: '/manager/bindingDrivers/' + truckId,
    method: 'get'
  })
}

